<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta
			name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"
		/>
		<meta name="format-detection" content="telephone=no" />
		<meta name="format-detection" content="email=no" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Cache-Control" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<title>常用功能</title>
		<!-- 引入 vant UI 组件库样式文件 -->
		<link rel="stylesheet" href="../common/css/vant-index.css" />
		<link rel="stylesheet" href="./css/menu.css" />
		<style type="text/css"></style>
	</head>
	<script>
		;(function () {
			if (
				typeof WeixinJSBridge == 'object' &&
				typeof WeixinJSBridge.invoke == 'function'
			) {
				handleFontSize()
			} else {
				if (document.addEventListener) {
					document.addEventListener(
						'WeixinJSBridgeReady',
						handleFontSize,
						false
					)
				} else if (document.attachEvent) {
					document.attachEvent('WeixinJSBridgeReady', handleFontSize)
					document.attachEvent('onWeixinJSBridgeReady', handleFontSize)
				}
			}
			function handleFontSize() {
				WeixinJSBridge.invoke('setFontSizeCallback', { fontSize: 0 })
				WeixinJSBridge.on('menu:setfont', function () {
					WeixinJSBridge.invoke('setFontSizeCallback', { fontSize: 0 })
				})
			}
		})()
	</script>

	<body style="-webkit-text-size-adjust: 100% !important">
		<div id="app" v-cloak>
			<div class="menu">
				<ul class="menuList">
					<!-- <li><img src="./img/menu/plan.png" @click="gotoSignin"/><span>打卡</span></li> -->
					<li id="launch-btn1"></li>
					<li id="launch-btn2"></li>
					<li>
						<img src="./img/menu/message.png" @click="gotoChatroom" /><span
							>咨询</span
						>
					</li>
					<li>
						<img src="./img/menu/science.png" @click="gotoKnowledge" /><span
							>科普文章</span
						>
					</li>
					<li>
						<img src="./img/menu/shop.png" @click="gotoShop" /><span>商城</span>
					</li>
					<li>
						<img src="./img/menu/qrcode.png" @click="gotoQrcode" /><span
							>我的二维码</span
						>
					</li>
					<li>
						<img src="./img/menu/dangan.png" @click="gotoFile" /><span
							>我的档案</span
						>
					</li>
					<li>
						<img src="./img/menu/help.png" @click="gotoHelp" /><span>帮助</span>
					</li>
					<!-- <li><img src="./img/menu/tool.png" /><span>工具箱</span></li> -->
				</ul>
			</div>
		</div>
	</body>
	<!-- <script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.9.0/vconsole.min.js"></script> -->
	<script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
	<!-- 引入 rem -->
	<script src="../common/js/rem.js"></script>
	<!-- 上线环境用 -->
	<script src="../common/js/vue.global.prod.js?time=202209061405"></script>
	<!-- 引入 UI 组件库 -->
	<script src="../common/js/vant.min.js"></script>
	<!-- axios 接口调用 -->
	<script src="../common/js/axios.min.js"></script>
	<script src="../base.js"></script>
	<script src="../common/js/url.min.js"></script>
	<script src="../common/js/rem.js"></script>

	<script type="module">
		// var vConsole = new VConsole();
		import {
			getAction,
			postAction,
			spliceUrl,
		} from '../common/js/api/vue3-axios-utils.js'

		import { wechatInit, wx_launch, is_weixn } from './js/wechat1.js'

		const menu = {
			data() {
				return {
					url: '/100/12/1001209',
					chatroomId: '',
				}
			},
			created() {
				this.patientId = url('?userid') || ''
				this.getDoctorPaient()
				wechatInit()
				setTimeout(() => {
					this.gotoSignin()
				}, 500)
			},
			methods: {
				// 通过获取医患关系获取聊天室id
				getDoctorPaient() {
					getAction(spliceUrl(this.url), {
						patientId: this.patientId,
						doctorId: '',
					}).then(res => {
						res = res.data
						console.log(res)
						if (res.success) {
							this.chatroomId = res.result
						}
					})
				},
				gotoSignin() {
					const content = `
						<div>
							<img src="https://h5.lingduhealth.com/patient/img/menu/plan.png"/>
							<span>打卡</span>
						</div>
						<style>
							div {display:flex;justify-content: center;align-items: center;flex-direction: column;font-size: 16px;color: #999999;}
							img {width: 48px;height: 48px;margin-bottom:8px;}
						</style>
					`
					let launchParams1 = {
						eleId: 'launch-btn1', // 元素id
						url: 'pages/index/index.html', // 跳转小程序的页面路径
						content: content, // 自定义的html内容
						appid: 'gh_95227d082adb',
					}
					wx_launch(launchParams1)

					// const content1 = `
					// 	<div>
					// 		<img src="https://h5.lingduhealth.com/patient/img/menu/tool.png"/>
					// 		<span>工具箱</span>
					// 	</div>
					// 	<style>
					// 		div {display:flex;justify-content: center;align-items: center;flex-direction: column;font-size: 16px;color: #999999;}
					// 		img {width: 48px;height: 48px;margin-bottom:8px;}
					// 	</style>
					// `
					// let launchParams2 = {
					// 	eleId: 'launch-btn2', // 元素id
					// 	url: 'pages/index/index.html', // 跳转小程序的页面路径
					// 	content: content1, // 自定义的html内容
					// 	appid: 'gh_f8c6c4b4cd8c',
					// }
					// wx_launch(launchParams2)
				},
				gotoChatroom() {
					if (this.chatroomId) {
						window.location.href =
							'https://qywechat.lingduhealth.com/chatroom?roomid=' +
							this.chatroomId +
							'&client=patient' +
							'&userid=' +
							this.patientId
					} else {
						vant.Toast('请先关联医生')
					}
				},
				gotoFile() {
					localStorage.setItem('pid', this.patientId)
					window.location.href = '../fileSetting/index.html'
				},
				gotoQrcode() {
					window.location.href = './qrcode.html?userid=' + this.patientId
				},
				gotoShop() {
					// this.$toast({
					// 	message: '商城升级中，请稍后再试',
					// })
					window.location.href =
						'https://shop.lingduhealth.com/mall/mallIndex.html?patient_id=' +
						this.patientId
				},
				gotoKnowledge() {
					window.location.href = '../dtrd-website/knowledge.html'
				},
				gotoHelp() {
					window.location.href = '../WeappHealthy/helpList.html'
				},
			},
		}

		const app = Vue.createApp(menu)

		app.use(vant)

		// 通过 CDN 引入时不会自动注册 Lazyload 组件
		// 可以通过下面的方式手动注册
		app.use(vant.Lazyload)

		// 调用函数组件，弹出一个 Toast
		// vant.Toast("刷新成功");

		app.mount('#app')
	</script>
</html>
